package bb.lanxing.databinding.unit;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;

public class DistanceUnit extends Unit {
    public DistanceUnit(String str) {
        super(str, "m");
    }

    public DistanceUnit(String str, DecimalFormat decimalFormat) {
        super(str, "m", decimalFormat);
    }

    @Override
    String convertToMetric(String str) {
        this.valueMetric = this.numberDecimalFormat.format(new BigDecimal(str).multiply(new BigDecimal("1.60934")));
        return this.valueMetric;
    }

    @Override
    String convertToBritish(String str) {
        this.valueBritish = this.numberDecimalFormat.format(new BigDecimal(str).multiply(new BigDecimal("0.621371")));
        return this.valueBritish;
    }

    @Override
    String convertToMetric(String str, int i) {
        this.valueMetric = this.numberDecimalFormat.format(new BigDecimal(str).multiply(new BigDecimal("1.60934")).setScale(i, RoundingMode.HALF_UP));
        return this.valueMetric;
    }

    @Override
    String convertToBritish(String str, int i) {
        this.valueBritish = this.numberDecimalFormat.format(new BigDecimal(str).multiply(new BigDecimal("0.621371")).setScale(i, RoundingMode.HALF_UP));
        return this.valueBritish;
    }

    @Override
    public String getUnitString(String str) {
        return str.equals("m") ? " km" : str.equals("f") ? " Mi" : " ";
    }
}
